home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 51 / Amiga Format CD51 (2000-03-10)(Future Publishing)(GB)[!][issue 2000-04].iso / -in_the_mag- / pdselect / blizkick / modules / waitide.asm < prev   
Assembly Source File  |  2000-02-16  |  3KB  |  175 lines

  1. ; FILE: Source:modules/WaitIDE.ASM          REV: 9 --- Fix KS to wait all IDE devices.
  2.  
  3. ;
  4. ; Fix scsi.device to wait all IDE devices
  5. ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6. ; Added support for 43.17 scsi.device although it doesn't work. :)
  7. ; Maybe 43.18 will work then.
  8. ;
  9. ; Written by Harry Sintonen.
  10. ; This source code is Public Domain.
  11. ;
  12.  
  13.     incdir    "include:"
  14.     include    "blizkickmodule.i"    ; Some required...
  15.  
  16.     SECTION    PATCH,CODE
  17. _DUMMY_LABEL
  18.     BK_PTC
  19.  
  20. ; Code is run with following incoming parameters:
  21. ;
  22. ; a0=ptr to ROM start (buffer)    eg. $1DE087B8
  23. ; a1=ptr to ROM start (ROM)    eg. $00F80000 (do *not* access!)
  24. ; d0=ROM lenght in bytes    eg. $00080000
  25. ; a2=ptr to _FindResident routine (will search ROM buffer for resident tag):
  26. ;    CALL: jsr (a2)
  27. ;      IN: a0=ptr to ROM, d0=rom len, a1=ptr to resident name
  28. ;     OUT: d0=ptr to resident (buf) or NULL
  29. ; a3=ptr to _InstallModule routine (can be used to plant a "module"):
  30. ;    CALL: jsr (a3)
  31. ;      IN: a0=ptr to ROM, d0=rom len, a1=ptr to module, d6=dosbase
  32. ;     OUT: d0=success
  33. ; a4=ptr to _Printf routine (will dump some silly things (errormsg?) to stdout ;-)
  34. ;    CALL: jsr (a4)
  35. ;      IN: a0=FmtString, a1=Array (may be 0), d6=dosbase
  36. ;     OUT: -
  37. ; d6=dosbase, a6=execbase
  38. ;
  39. ; Code should return:
  40. ;
  41. ; d0=true if succeeded, false if failed.
  42. ; d1-d7/a0-a6 can be trashed. a7 *must* be preserved! ;-)
  43.  
  44.     cmp.w    #39,($C,a0)        ; V37 support _could_ be added...
  45.     bhs.b    .cont
  46.     moveq    #0,d0
  47.     rts
  48.  
  49. .cont    movem.l    d0/a0-a1,-(sp)
  50.  
  51.     lea    (scsiname,pc),a1
  52.     jsr    (a2)
  53.     tst.l    d0
  54.     beq    .fail
  55.     move.l    d0,a5
  56.  
  57.     move.l    a5,a0            ; a0=beg of search
  58.     lea    (16384,a0),a1        ; a1=end of search
  59.  
  60.     move.l    #$FFC0FFFF,d1
  61.     move.l    #$70001E80,d2
  62.     move.l    #$196F0003,d3
  63.     move.l    #$0000122C,d4
  64.     move.l    #$0000102C,d5
  65.  
  66. .find    addq.l    #2,a0
  67.     cmp.l    a1,a0
  68.     bhs.b    .try_new
  69.     move.l    (a0),d0
  70.     and.l    d1,d0
  71.     cmp.l    d2,d0
  72.     bne.b    .find
  73.     cmp.l    (4,a0),d3
  74.     bne.b    .find
  75.     move.l    (8,a0),d0
  76.     and.l    d1,d0
  77.     cmp.l    d4,d0
  78.     bne.b    .find
  79.     move.l    (12,a0),d0
  80.     and.l    d1,d0
  81.     cmp.l    d5,d0
  82.     bne.b    .find
  83.  
  84.     tst.b    (1,a0)
  85.     beq.b    .is_only2nd
  86.  
  87. .doit    move.b    #$7F,(1,a0)
  88.     moveq    #1,d0
  89.     bra.b    .noerr
  90.  
  91. .is_only2nd    lea    (-10,a0),a0
  92.     cmp.b    #$70,(a0)
  93.     bne.b    .not_found
  94.     tst.b    (1,a0)
  95.     bne.b    .doit
  96.     bra    .not_found
  97.  
  98.  
  99.     ; Scan for new: (43.17 at least)
  100.  
  101. .try_new    move.l    a5,a0            ; a0=beg of search
  102.     lea    (16384,a0),a1        ; a1=end of search
  103.  
  104.     IFGT    0
  105.  
  106.     move.l    #$B23C<<16!13,d1
  107.     move.l    #$FFFFFC00,d2
  108.     move.l    #$66000000,d3
  109.     move.l    #$FFC0FFFF,d4
  110.     move.l    #$7000082F,d5
  111.  
  112. .nfind    addq.l    #2,a0
  113.     cmp.l    a1,a0
  114.     bhs.b    .not_found
  115.     cmp.l    (a0),d1
  116.     bne.b    .nfind
  117.     move.l    (4,a0),d0
  118.     and.l    d2,d0
  119.     cmp.l    d3,d0
  120.     bne.b    .nfind
  121.     move.l    (8,a0),d0
  122.     and.l    d4,d0
  123.     cmp.l    d5,d0
  124.     bne.b    .nfind
  125.  
  126.     addq.l    #8,a0
  127.     bra.b    .doit
  128.  
  129.     ELSE
  130.  
  131.     move.l    #$FFFFFFC0,d1
  132.     move.l    #$1EBC0000,d2
  133.     move.l    #$FFFFFFC0,d3
  134.     move.l    #$102C0000,d4
  135.  
  136. .nfind    addq.l    #2,a0
  137.     cmp.l    a1,a0
  138.     bhs.b    .not_found
  139.     move.l    (a0),d0
  140.     and.l    d1,d0
  141.     cmp.l    d2,d0
  142.     bne.b    .nfind
  143.     move.l    (4,a0),d0
  144.     and.l    d3,d0
  145.     cmp.l    d4,d0
  146.     bne.b    .nfind
  147.  
  148.     addq.l    #2,a0
  149.     bra.b    .doit
  150.  
  151.     ENDC
  152.  
  153. .not_found    move.l    (RT_IDSTRING,a5),a0
  154.     sub.l    (2*4,sp),a0        ;[a1]
  155.     add.l    (1*4,sp),a0        ;[a0]
  156.     move.l    a0,-(sp)
  157.     move.l    sp,a1
  158.     lea    (fmt1,pc),a0
  159.     jsr    (a4)
  160.     addq.l    #4,sp
  161.  
  162. .fail    moveq    #0,d0
  163. .noerr    lea    (3*4,sp),sp
  164.     rts
  165.  
  166.  
  167. scsiname    dc.b    'scsi.device',0
  168. fmt1    dc.b    'Couldn''t patch %s',0
  169.  
  170.  
  171.     SECTION    VERSION,DATA
  172.  
  173.     dc.b    '$VER: WaitIDE_PATCH 1.1 (5.6.97)',0
  174.  
  175.